﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using Resources;

namespace KPIS.GERP.WEB.GAMS.Class
{
    public class GridHelper
    {
        public static string CheckBox(int id)
        {
            string strResult = "<label><input type='checkbox' name='deleteIds' value='" + id + "' /><span class='lbl'></span></label>";
            return strResult;
        }

        public static string InLineButton(string DetailsUrl, string EditUrl, string DeleteUrl)
        {
            var strResult = new StringBuilder();
                
            strResult.Append("<div class='hidden-phone visible-desktop btn-group'>");

            if (!string.IsNullOrWhiteSpace(DetailsUrl))
            {
	            strResult.Append("<a class='btn btn-mini btn-grey' data-rel='tooltip' href='");
                strResult.Append(DetailsUrl);
                strResult.Append("' role='button'><i class='icon-search bigger-120'></i></a>");
            }

            if (!string.IsNullOrWhiteSpace(EditUrl))
            {
	            strResult.Append("<a class='btn btn-mini btn-success' data-rel='tooltip' href='");
                strResult.Append(EditUrl);
                strResult.Append("' role='button'><i class='icon-edit bigger-120'></i></a>");
            }

            if (!string.IsNullOrWhiteSpace(DeleteUrl))
            {
	            strResult.Append("<a class='btn btn-mini btn-danger' data-rel='tooltip' href='#' onclick='bootbox.confirm('"); 
	            strResult.Append(PopupMessageLocalization.ConfirmDelete);
                strResult.Append("', function(result) { if (result) window.location.href='");
                strResult.Append(DeleteUrl); 
	            strResult.Append("' role='button'><i class='icon-trash bigger-120'></i></a>");
            }

            strResult.Append("</div><div class='hidden-desktop visible-phone'><div class='inline position-relative'>");
            strResult.Append("<button class='btn btn-minier btn-yellow dropdown-toggle' data-toggle='dropdown'>");
            strResult.Append("<i class='icon-caret-down icon-only bigger-120'></i></button><ul class='dropdown-menu dropdown-icon-only dropdown-yellow pull-right dropdown-caret dropdown-close'>");
            
            if (!string.IsNullOrWhiteSpace(DetailsUrl))
            {
				strResult.Append("<li><a href='");
                strResult.Append(DetailsUrl);
                strResult.Append("' class='tooltip-grey' data-rel='tooltip' title='");
                strResult.Append(IndexLocalization.Details);
                strResult.Append("' data-placement='left'><span class='grey'><i class='icon-search'></i></span></a></li>");
            }
			
            if (!string.IsNullOrWhiteSpace(EditUrl))
            {
                strResult.Append("<li><a href='");
                strResult.Append(EditUrl);
                strResult.Append("' class='tooltip-success' data-rel='tooltip' title='");
                strResult.Append(IndexLocalization.Edit);
                strResult.Append("' data-placement='left'><span class='green'><i class='icon-edit'></i></span></a></li>");
            }

            if (!string.IsNullOrWhiteSpace(DeleteUrl))
            {
                strResult.Append("<li><a href='");
                strResult.Append(DeleteUrl);
                strResult.Append("' class='tooltip-error' data-rel='tooltip' title='");
                strResult.Append(IndexLocalization.Delete);
                strResult.Append("' data-placement='left'><span class='red'><i class='icon-trash'></i></span></a></li>");
            }

            strResult.Append("</ul></div></div>");
            return strResult.ToString();
        }
    }
}